package com.sgb.kjwl.view.ui.fragment.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.android.material.tabs.TabLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentLeaseListBinding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.BiddingEntity;
import com.sgb.jicai.entity.CentralizedMiningEntity;
import com.sgb.jicai.entity.JiCaiHomeListRequestBean;
import com.sgb.kjwl.model.entity.lease.AskLeaseSheBeiEntity;
import com.sgb.kjwl.model.entity.lease.LeaseListEntity;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.jicai.view.adapter.CentralizedMiningCuttingLineAdapter;
import com.sgb.kjwl.view.ui.adapter.home.LeaseListAndVideoAdapter;
import com.sgb.kjwl.view.ui.adapter.machine.AskLeaseAndVideoAdapter;
import com.sgb.kjwl.view.ui.adapter.pick.PickBidingAdapter;
import com.sgb.kjwl.viewmodel.home.LeaseListFragmentModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.base.model.entity.ListResponse;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.decoration.RecyclerCustomDecoration;
import com.swgk.core.recyclerview.decoration.RecyclerViewItemDecoration;
import com.swgk.core.util.ClickUtils;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * 租赁首页推荐列表数据展示
 */
public class LeaseListFragment extends AppLazyFragment {

    @Inject
    LeaseListFragmentModel viewModel;
    FragmentLeaseListBinding binding;
    private String[] modeTypeList = {"求租信息", "竞价租赁", "集采租赁"};
    private String[] categoryTypeList = {"全部", "机械租赁", "设备租赁", "车辆租赁", "房产租赁", "土地租赁", "工厂租赁", "农机租赁"};
    private int type = 0;
    private int modeType = 0;
    private int categoryType = 0;
    private String firstCategoryNo = "";
    private List<DictEntity3> classlyList;//分类

    private AskLeaseAndVideoAdapter askLeaseAdapter;//求租信息
    private PickBidingAdapter pickingAdapter;//竞价租赁
    private CentralizedMiningCuttingLineAdapter centralizedMiningAdapter;//集采租赁
    //    private LeaseListAdapter leaseListAdapter;
    private LeaseListAndVideoAdapter leaseListAdapter;
    private List<LeaseListEntity> leaseList = new ArrayList<>();
    private List<AskLeaseSheBeiEntity> askLeaseList = new ArrayList<>();

    public static LeaseListFragment newInstance(int type) {
        LeaseListFragment fragment = new LeaseListFragment();
        Bundle args = new Bundle();
        args.putInt("type", type);
//        args.putInt("ARG_PARAM_POS", 0);//BaseHeightViewPagerFragment 用来计算高度
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_lease_list, container, false);
        return binding.getRoot();
    }


    @Override
    public void initView() {
        initExtra();
        initAdapter();
        initTab();
    }

    @Override
    protected void onLazyLoad() {
        if (type == 0 || type == 2) {//出租大厅
            binding.TabMode.setVisibility(View.GONE);
            binding.TabModeLine.setVisibility(View.GONE);
            categoryTypeList = new String[]{"全部", "机械租赁", "设备租赁", "车辆租赁", "房产租赁", "土地租赁", "工厂租赁", "农机租赁"};
        } else if (type == 1) {//需求大厅
            binding.TabMode.setVisibility(View.VISIBLE);
            binding.TabModeLine.setVisibility(View.VISIBLE);
            categoryTypeList = new String[]{"全部", "机械求租", "设备求租", "车辆求租", "房产求租", "土地求租", "工厂求租", "农机求租"};
            setTabMode();
        } else if (type == 3) {//热门推荐
            binding.TabMode.setVisibility(View.GONE);
            binding.TabModeLine.setVisibility(View.GONE);
            categoryTypeList = new String[]{"机械租赁", "设备租赁", "车辆租赁", "房产租赁", "土地租赁", "工厂租赁", "农机租赁"};
        }
        setTabCategory();
    }

    private void initExtra() {
        if (getArguments() != null) {
            type = getArguments().getInt("type");
        }
    }


    private void loadData(boolean isLoadMore) {
        if (type == 0 || type == 2) {//出租大厅
            viewModel.isSelf = (type == 2) ? "1" : null;//是否筛选自营
            if (categoryType == 0) {//全部
                binding.tabClassify.setVisibility(View.GONE);
                binding.tabClassifyLine.setVisibility(View.GONE);
                viewModel.getMachineModel(categoryType, firstCategoryNo, isLoadMore);
            } else if (categoryType == 1) {//机械
                viewModel.getMachineModel(categoryType, firstCategoryNo, isLoadMore);
            } else if (categoryType == 2) {//设备
                viewModel.getMachineModel(categoryType, firstCategoryNo, isLoadMore);
            } else if (categoryType == 3) {//车辆
                viewModel.getAllListByCar(firstCategoryNo, isLoadMore);
            } else if (categoryType == 4) {//房产
                viewModel.getAllListByHouse(firstCategoryNo, isLoadMore);
            } else if (categoryType == 5) {//土地
                viewModel.getAllListByLand(firstCategoryNo, isLoadMore);
            } else if (categoryType == 6) {//工厂
                viewModel.getAllListByFactory(firstCategoryNo, isLoadMore);
            } else if (categoryType == 7) {//农机
                viewModel.getAllListByFram(firstCategoryNo, isLoadMore);
            }
        } else if (type == 1) {//需求大厅
            if (modeType == 1) {//求租信息
                viewModel.getDataList(categoryType == 0 ? "" : String.valueOf(categoryType), firstCategoryNo, isLoadMore);
            } else if (modeType == 2) {//竞价租赁
//                String goodsType = String.valueOf(categoryType);
                String type = "";
                if(categoryType==1){
                    type ="1";//机械
                }else if(categoryType==2){
                    type ="5";//设备
                }
//                if (!TextUtils.isEmpty(firstCategoryNo)) {
//                    goodsType = firstCategoryNo;
//                }
                viewModel.getBiddingList(type,firstCategoryNo, isLoadMore);
            } else if (modeType == 3) {//集采租赁
                JiCaiHomeListRequestBean requestBean = new JiCaiHomeListRequestBean();
                if (categoryType == 0) {//全部
                    requestBean.setGroupbuyClass("999");//全部类别
                } else if (categoryType == 1) {//机械
                    requestBean.setGroupbuyClass("2");
                } else if (categoryType == 2) {//设备
                    requestBean.setGroupbuyClass("3");
                }
                requestBean.setTypeNo(firstCategoryNo);//一级分类
                requestBean.setGroupBuyMode("1");//需方发起
                viewModel.getJiCaiList(requestBean, isLoadMore);
            }
        } else if (type == 3) {//热门推荐
            viewModel.getHomeRecommend(categoryType + 1, firstCategoryNo, isLoadMore);//热门推荐 没有全部,下标应该从1开始,因此加1
        }
    }

    private void initAdapter() {
        //热门推荐
//        if (leaseHomeRecommendAdapter == null) {
//            leaseHomeRecommendAdapter = new LeaseHomeRecommendAdapter(getActivity(), null);
//        }
//        leaseHomeRecommendAdapter.setOnItemClick(new AdapterOnItemClick<LeaseHomeRecommendEntity>() {
//            @Override
//            public void onItemClick(LeaseHomeRecommendEntity entity, int position) {
//                if (!ClickUtils.isDoubleClick())
//                    viewModel.getH5Url(entity.getType(), entity.getDataId());
//            }
//        });

        if (leaseListAdapter == null) {
            leaseListAdapter = new LeaseListAndVideoAdapter(leaseList);
//            binding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//            binding.recyclerView.addItemDecoration(new RecyclerCustomDecoration(0, 0, 0,
//                    getActivity().getResources().getDimension(R.dimen.dp5),
//                    Color.TRANSPARENT));
            leaseListAdapter.bindToRecyclerView(binding.recyclerView);
            leaseListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                @Override
                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                    if (!ClickUtils.isDoubleClick()) {
                        viewModel.getH5Url(leaseList.get(position).getType(), leaseList.get(position).getDataId());
                    }
                }
            });
        }

//        //出租大厅适配器
//        if (leaseListAdapter == null) {
//            leaseListAdapter = new LeaseListAdapter(getActivity(), null);
//        }
//        leaseListAdapter.setOnItemClick(new AdapterOnItemClick<LeaseListEntity>() {
//            @Override
//            public void onItemClick(LeaseListEntity entity, int position) {
//                if (!ClickUtils.isDoubleClick()) {
//                    viewModel.getH5Url(entity.getType(), entity.getDataId());
//                }
//            }
//        });

        //求租信息
        if (askLeaseAdapter == null) {
            askLeaseAdapter = new AskLeaseAndVideoAdapter(askLeaseList);
        }
        askLeaseAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                if (!ClickUtils.isDoubleClick()) {
                    viewModel.getH5UrlByAskLease(askLeaseList.get(position).getType(), askLeaseList.get(position).getId());
                }
            }
        });
//        askLeaseAdapter.setOnItemClick(new AdapterOnItemClick<AskLeaseSheBeiEntity>() {
//            @Override
//            public void onItemClick(AskLeaseSheBeiEntity entity, int p) {
//                if (!ClickUtils.isDoubleClick()) {
//                    viewModel.getH5UrlByAskLease(entity.getType(), entity.getId());
//                }
//            }
//        });

        if (pickingAdapter == null) {
            pickingAdapter = new PickBidingAdapter(getActivity(), null);
        }
        pickingAdapter.setType("");//设置改属性是为了取消多余的标签名称
        pickingAdapter.onIChildClick(new PickBidingAdapter.IChildClick() {
            @Override
            public void onClick(BiddingEntity tenderListEntity) {
                if (!ClickUtils.isDoubleClick()) {
                    viewModel.getUrlSetting(tenderListEntity.getId());
                }
            }
        });

        //集采租赁
        if (centralizedMiningAdapter == null) {
            centralizedMiningAdapter = new CentralizedMiningCuttingLineAdapter(getActivity(), null);
        }
        centralizedMiningAdapter.setOnItemClick(new AdapterOnItemClick<CentralizedMiningEntity>() {
            @Override
            public void onItemClick(CentralizedMiningEntity centralizedMiningEntity, int position) {
                if (!ClickUtils.isDoubleClick()) {
                    viewModel.getH5UrlByJC(centralizedMiningEntity.getNo());
                }
            }
        });

        initRecyclerView();
    }

    /**
     *
     */
    private void initRecyclerView() {
//        binding.recyclerView.setAdapter(leaseListAdapter);
//        binding.recyclerView.setPullRefreshEnabled(false);
//        binding.recyclerView.setLoadingMoreEnabled(false);
        if (type != 1) {
            binding.recyclerView.addItemDecoration(new RecyclerViewItemDecoration(getResources().getDimension(R.dimen.dp15)));
            binding.recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
        } else {
            binding.recyclerView.addItemDecoration(new RecyclerCustomDecoration(0, 0, 0,
                    getActivity().getResources().getDimension(R.dimen.dp1),
                    getActivity().getResources().getColor(R.color.color_F5F5F5)));
            binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        }
//        binding.recyclerView.setFootViewText("加载中", "我也是有底线的");
        binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                //解决RecyclerView与外层SwipeRefreshLayout在部分机型上滑动冲突
                ((LeaseFragment3) getParentFragment()).setEnabled(recyclerView.getChildCount() == 0 || recyclerView.getChildAt(0).getTop() >= 0);
            }
        });
        binding.tvMore.setOnClickListener(v -> onLoadMore());
        binding.smartRefresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                loadData(true);
                binding.smartRefresh.finishLoadMore();
            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                loadData(false);
                binding.smartRefresh.finishRefresh();
            }
        });
    }

    private void initTab() {
        binding.TabMode.setTabMode(TabLayout.MODE_SCROLLABLE);
        binding.TabMode.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                modeType = tab.getPosition() + 1;
                if (modeType == 1) {//求租信息
                    categoryTypeList = new String[]{"全部", "机械求租", "设备求租", "车辆求租", "房产求租", "土地求租", "工厂求租", "农机求租"};
                } else if (modeType == 2) {//竞价租赁
                    categoryTypeList = new String[]{"全部", "机械租赁", "设备租赁"};
                } else if (modeType == 3) {//集采租赁
                    categoryTypeList = new String[]{"全部", "机械租赁", "设备租赁"};
                }
                setTabCategory();
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        binding.tabCategory.setTabMode(TabLayout.MODE_SCROLLABLE);
        binding.tabCategory.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                categoryType = tab.getPosition();
                firstCategoryNo = "";
                if ("全部".equals(categoryTypeList[tab.getPosition()])) {
                    binding.tabClassify.setVisibility(View.GONE);
                    loadData(false);
                } else {
                    binding.tabClassify.setVisibility(View.VISIBLE);
                    if (type == 3) {
                        viewModel.getFilterTypeModel(String.valueOf(categoryType + 1));//热门推荐 没有全部,下标应该从1开始,因此加1
                    } else {
                        viewModel.getFilterTypeModel(String.valueOf(categoryType));
                    }
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        binding.tabClassify.setTabMode(TabLayout.MODE_SCROLLABLE);
        binding.tabClassify.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                firstCategoryNo = classlyList.get(tab.getPosition()).getId();
                loadData(false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    //提供给外部调用
    public void onLoadMore() {
        loadData(true);
    }

    //类目数据绑定
    public void setTabMode() {
        binding.TabMode.removeAllTabs();
        for (int i = 0; i < modeTypeList.length; i++) {
            binding.TabMode.addTab(binding.TabMode.newTab().setText(modeTypeList[i]));
        }
    }

    //类目数据绑定
    public void setTabCategory() {
        binding.tabCategory.removeAllTabs();
        for (int i = 0; i < categoryTypeList.length; i++) {
            binding.tabCategory.addTab(binding.tabCategory.newTab().setText(categoryTypeList[i]));
        }
        binding.tabCategory.getTabAt(0).select();
    }

    //分类数据绑定
    public void showCategoryList(List<DictEntity3> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        classlyList = list;
        binding.tabClassify.removeAllTabs();
        for (int i = 0; i < classlyList.size(); i++) {
            String tabName = classlyList.get(i).getName();
            if ("不限".equals(tabName)) {
                tabName = "全部";
            }
            binding.tabClassify.addTab(binding.tabClassify.newTab().setText(tabName));
        }
    }

    //提供给外部刷新此界面使用
    public void onRefresh() {
        loadData(false);
    }

    private void setMoreText(boolean b) {
//        binding.tvMore.setVisibility(b ? View.VISIBLE : View.GONE);
//        if (!b) {
//            binding.NestedScrollView.smoothScrollTo(0, 0);
//        }
    }

//    //热门推荐
//    public void showRecommendList(List<LeaseHomeRecommendEntity> list, boolean isLoadMore) {
//        binding.recyclerView.setAdapter(leaseHomeRecommendAdapter);
//        if (isLoadMore) {
////            binding.recyclerView.loadMoreComplete();
//            if (list != null && list.size() > 0) {
//                leaseHomeRecommendAdapter.addDatas(list);
////                binding.recyclerView.setNoMore(list.size() < viewModel.pageSize);
//                setMoreText(list.size() >= viewModel.pageSize);
//            } else {
////                binding.recyclerView.setNoMore(true);
//                setMoreText(false);
//            }
//        } else {
////            binding.recyclerView.refreshComplete();
//            if (list != null && list.size() > 0) {
//                leaseHomeRecommendAdapter.setDatas(list);
////                binding.recyclerView.setNoMore(list.size() < viewModel.pageSize);
//                binding.emptyView.setVisibility(View.GONE);
//                setMoreText(list.size() >= viewModel.pageSize);
//            } else {
//                leaseHomeRecommendAdapter.clearDatas();
//                binding.emptyView.setVisibility(View.VISIBLE);
////                binding.recyclerView.setNoMore(true);
//                setMoreText(false);
//            }
//        }
//        leaseHomeRecommendAdapter.notifyDataSetChanged();
//    }

    //出租列表返回（出租，自营，热门推荐）
    public void showList(ListResponse<List<LeaseListEntity>> response, boolean isLoadMore) {
        if (response == null && !isLoadMore) {
            binding.smartRefresh.setVisibility(View.VISIBLE);
            binding.emptyView.setVisibility(View.GONE);
            return;
        }
        List<LeaseListEntity> list = response.getList();
        if (list != null && list.size() >= 10 && response.getVideoProDict() != null && response.getVideoProDict().size() > 0) {
            LeaseListEntity listEntity = new LeaseListEntity();
            listEntity.setVideoProDict(response.getVideoProDict());
            list.add(listEntity);
        }
//        leaseListAdapter.bindToRecyclerView(binding.recyclerView);
        binding.recyclerView.setAdapter(leaseListAdapter);
        if (isLoadMore) {
//            binding.recyclerView.loadMoreComplete();
            if (list != null && list.size() > 0) {
//                leaseListAdapter.addDatas(list);
                leaseList.addAll(list);
//                binding.recyclerView.setNoMore(list.size() < viewModel.pageSize);
                setMoreText(list.size() >= viewModel.pageSize);
            } else {
//                binding.recyclerView.setNoMore(true);
                setMoreText(false);
            }
        } else {
//            binding.recyclerView.refreshComplete();
            if (list != null && list.size() > 0) {
                binding.smartRefresh.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                leaseList.clear();
                leaseList.addAll(list);
//                leaseListAdapter.setDatas(list);
//                binding.recyclerView.setNoMore(list.size() < viewModel.pageSize);
                setMoreText(list.size() >= viewModel.pageSize);
            } else {
                leaseList.clear();
//                leaseListAdapter.clearDatas();
                binding.smartRefresh.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
//                binding.recyclerView.setNoMore(true);
                setMoreText(false);
            }
        }
        leaseListAdapter.notifyDataSetChanged();
    }


    //求租信息
    public void showListAskLease(ListResponse<List<AskLeaseSheBeiEntity>> response, boolean isLoadMore) {
        if (response == null && !isLoadMore) {
            binding.smartRefresh.setVisibility(View.VISIBLE);
            binding.emptyView.setVisibility(View.GONE);
            return;
        }
        List<AskLeaseSheBeiEntity> list = response.getList();
        if (list != null && list.size() >= 10 && response.getVideoProDict() != null && response.getVideoProDict().size() > 0) {
            AskLeaseSheBeiEntity listEntity = new AskLeaseSheBeiEntity();
            listEntity.setVideoProDict(response.getVideoProDict());
            list.add(listEntity);
        }
        binding.recyclerView.setAdapter(askLeaseAdapter);
//        binding.recyclerView.refreshComplete();
        if (isLoadMore) {
//            binding.recyclerView.loadMoreComplete();
            if (null != list && list.size() > 0) {
//                askLeaseAdapter.addDatas(list);
                askLeaseList.addAll(list);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
//                binding.recyclerView.setNoMore(true);
                setMoreText(false);
            }
            binding.recyclerView.setVisibility(View.VISIBLE);
        } else {
//            binding.recyclerView.refreshComplete();
            if (null != list && list.size() > 0) {
                binding.smartRefresh.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
//                askLeaseAdapter.setDatas(list);
                askLeaseList.clear();
                askLeaseList.addAll(list);
//                binding.recyclerView.setNoMore(false);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
//                askLeaseAdapter.clearDatas();
                askLeaseList.clear();
                binding.smartRefresh.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                setMoreText(false);
            }
        }
        askLeaseAdapter.notifyDataSetChanged();
    }

    //竞价租赁
    public void showBindingList(List<BiddingEntity> list, boolean isLoadMore) {
        binding.recyclerView.setAdapter(pickingAdapter);
        if (isLoadMore) {
//            binding.recyclerView.loadMoreComplete();
            if (null != list && list.size() > 0) {
                pickingAdapter.addDatas(list);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
//                binding.recyclerView.setNoMore(true);
                setMoreText(false);
            }
        } else {
//            binding.recyclerView.refreshComplete();
            if (null != list && list.size() > 0) {
                binding.smartRefresh.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                pickingAdapter.setDatas(list);
//                binding.recyclerView.setNoMore(false);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
                pickingAdapter.clearDatas();
                binding.smartRefresh.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                setMoreText(false);
            }
        }
    }

    /**
     * 集采租赁
     *
     * @param list
     * @param isLoadMore
     */
    public void setJiCaiList(List<CentralizedMiningEntity> list, boolean isLoadMore) {
        binding.recyclerView.setAdapter(centralizedMiningAdapter);
        if (isLoadMore) {
//            binding.recyclerView.loadMoreComplete();
            if (list != null && list.size() > 0) {
                centralizedMiningAdapter.addDatas(list);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
//                binding.recyclerView.setNoMore(true);
                setMoreText(false);
            }
        } else {
//            binding.recyclerView.refreshComplete();
            if (list != null && list.size() > 0) {
                binding.emptyView.setVisibility(View.GONE);
                binding.smartRefresh.setVisibility(View.VISIBLE);
                centralizedMiningAdapter.setDatas(list);
//                binding.recyclerView.setNoMore(false);
                setMoreText(list.size() == viewModel.pageSize);
            } else {
                centralizedMiningAdapter.clearDatas();
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.smartRefresh.setVisibility(View.GONE);
                setMoreText(false);
            }
        }
    }

}